package com.lbj.utils;



import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DynamicQuerySql {
    public static String getSql(Map<String,String> conditions, String tableName){
        StringBuilder builder = new StringBuilder("select * from "+ tableName +" where 1=1 ");
        for (String s : conditions.keySet()) {
            builder.append("and ");
            builder.append(s);
            builder.append(" like ?");
            builder.append(" ");
        }
        return builder.toString();
    }

    public static List<String> getCondition(Map<String,String> conditions){
        List<String> list  = new ArrayList<>();
        HashMap<String ,String > hashMap  = new HashMap<>();
        for (String s : conditions.keySet()) {
            list.add(conditions.get(s));
        }
        return list;
    }
}
